import os
import sys
import time
import pickle#序列化
from string import digits
from win32com.client import Dispatch #调用大漠插件的库
from apscheduler.schedulers.background import BackgroundScheduler#后台调度器
from apscheduler.jobstores.memory import MemoryJobStore
from apscheduler.triggers.interval import IntervalTrigger

#-----------节点编辑器需要的库--------------------
import json
#------------------------------------------------

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *      #无边框,选框,动画
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
_path = ''
_path = sys.argv[0]
_path = os.path.dirname(_path)
print(_path[-8:])
if _path[-8:] == 'SeerMain':
    _path = str(_path[0:-8])
sys.path.append(_path + '\\Code')
#动态导入之前必须加入路径，否则找不到Code
SeerDm = __import__('SeerDm',fromlist=["*"])
SeerTask = __import__('SeerTask',fromlist=["*"])
SeerFight = __import__('SeerFight',fromlist=["*"])
SeerGlobal = __import__('SeerGlobal',fromlist=["*"])
SeerPVP = __import__('SeerPVP',fromlist=["*"])


def main():
    _hwnd = 0
    _task_id = ''
    try:
        _hwnd = sys.argv[1]
    except:
        pass
    try:
        _task_id = sys.argv[2]
    except:
        pass
    
    
    SeerGlobal._init()
    seerDm = SeerDm.DmBase(_hwnd,_path)
    task = SeerTask.TaskManager(seerDm,_path)
    zhan = SeerFight.ZhanDou(seerDm)
    pvp = SeerPVP.PVP(seerDm)
    SeerGlobal.set_value('SeerDm',seerDm)
    SeerGlobal.set_value('Task',task)
    SeerGlobal.set_value('Zhan',zhan)
    SeerGlobal.set_value('SeerPVP',pvp)
    
    task.addOneTask(_task_id)

if __name__ == "__main__":
    app=QtWidgets.QApplication(sys.argv)
    #QApplication作为QT主脉必须在最前面
    main()
    sys.exit(app.exec_())
